﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace G28BS.Models
{
    public class AppRepository : IAppRepository
    {
        private AppDataContext db = new AppDataContext();

        public IEnumerable<UserProfile> userProfiles
        {
            get
            {
                return db.UserProfiles;
            }
        }

        public IEnumerable<GameRoom> gameRooms
        {
            get
            {
                return db.GameRooms;
            }
        }

        public IEnumerable<FinishedGame> finishedGames
        {
            get
            {
                return db.FinishedGames;
            }
        }

        public IEnumerable<Slot> slots
        {
            get
            {
                return db.Slots;
            }
        }

        public IEnumerable<Invitation> invitations
        {
            get
            {
                return db.Invites;
            }
        }

        public IEnumerable<Game> games {
            get
            {
                return db.Games;
            }
        }

        public IEnumerable<GameResult> gameResults {
            get
            {
                return db.GameResults;
            }
        }

        public IEnumerable<Event> events {
            get
            {
                return db.Events;
            }
        }

        public IEnumerable<Group> groups {
            get
            {
                return db.Groups;
            }
        }

        public IEnumerable<Tournament> tournaments {
            get
            {
                return db.Tournaments;
            }
        }


        //public IEnumerable<Rank> ranks
        //{
        //    get
        //    {
        //        return db.Ranks;
        //    }
        //}

        public IEnumerable<RankmkII> rankIIs
        {
            get
            {
                return db.RankIIs;
            }
        }

        public IEnumerable<tttResult> tttresults
        {
            get
            {
                return db.tttResults;
            }
        }

        public IEnumerable<Error> errors
        {
            get
            {
                return db.errors;
            }
        }

        public void AddUserProfile(UserProfile userProfile)
        {
            db.UserProfiles.Add(userProfile);
        }

        public void AddGameRoom(GameRoom gameRoom)
        {
            db.GameRooms.Add(gameRoom);
        }

        public void AddFinishedGame(FinishedGame finishedGame)
        {
            db.FinishedGames.Add(finishedGame);
        }


        public void AddSlots(List<Slot> slots)
        {
            foreach (var slot in slots)
	        {
                db.Slots.Add(slot);
		 	}
        }

        public void AddInvitation(Invitation invitation)
        {
 	        db.Invites.Add(invitation);
        }

        public void AddGame(Game game)
        {
 	        db.Games.Add(game);
        }

        public void AddGameResult(GameResult gameResult)
        {
 	        db.GameResults.Add(gameResult);
        }

        public void AddEvent(Event e)
        {
 	        db.Events.Add(e);
        }

        public void AddGroup(Group group)
        {
            db.Groups.Add(group);
        }

        public void AddTournament(Tournament tournament)
        {
            db.Tournaments.Add(tournament);
        }

        public void AddtttResult(tttResult tttresults)
        {
            db.tttResults.Add(tttresults);
        }

        //public void AddRank(Rank rankings)
        //{
        //    db.Ranks.Add(rankings);
        //}

        public void AddRankII(RankmkII userRankRow)
        {
            db.RankIIs.Add(userRankRow);
        }

        public void AddError(Error error)
        {
            db.errors.Add(error);
        }

        public void Save()
        {
            db.SaveChanges();
        }

    }
}